package services

import (
	"kop/pb"
)

// 连接服务器验证Token
//type BattleService struct{}
//
//// PVP战斗
//func (b *BattleService) PVP(ctx context.Context, req *wrappers.Int32Value) (*pb.PVPAPIReply, error) {
//
//	var reply pb.PVPAPIReply
//
//	var roleID = getRoleID(ctx)
//
//	// 对手角色
//	var role2 = roleC.GetRole(req.Value)
//
//	if role2.ServerID != getServerID(ctx) {
//		return &reply, errors.New("不同服务器打不了")
//	}
//
//	var waitGroup errgroup.Group
//
//	// 船长
//	waitGroup.Go(func() error {
//
//		reply.Fighter1 = captainC.GetCaptains(roleID)
//		return nil
//	})
//
//	// 对手船长
//	waitGroup.Go(func() error {
//
//		reply.Fighter2 = captainC.GetCaptains(role2.RoleID)
//		return nil
//	})
//
//	var err error
//	if err = waitGroup.Wait(); err != nil {
//		return &reply, err
//	}
//
//	sort.Sort(Captains(reply.Fighter1))
//	sort.Sort(Captains(reply.Fighter2))
//
//	reply.BattleResult, err = battleC.Battle(reply.Fighter1, reply.Fighter2)
//
//	if err == nil {
//		//b.removeSkill(reply.Fighter1)
//		//b.removeSkill(reply.Fighter2)
//	}
//
//	return &reply, err
//}

type Captains []*pb.Captain

func (c Captains) Len() int           { return len(c) }
func (c Captains) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
func (c Captains) Less(i, j int) bool { return c[i].Power > c[j].Power }

func (c Captains) setSkillNil() {
	for _, captain := range c {
		//captain.Skill1 = nil // 技能1客户端还有用
		captain.Skill2 = nil
		captain.Skill3 = nil
		captain.RingAttribute = nil
		//captain.MaidAttribute = nil
		captain.ClassUpItems = nil
		captain.Talents = nil
	}
}
